<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$webtitle}</title>
    
    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/news/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__STATIC__/news/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="__STATIC__/news/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/bootstrap-datetimepicker.min.css">
    <link href="__STATIC__/news/css/animate.min.css" rel="stylesheet">
    <link href="__STATIC__/news/css/style.min.css?v=4.0.0" rel="stylesheet">
    <script src="http://www.jq22.com/jquery/1.11.1/jquery.min.js"></script>
    <style type="text/css">
    th{
        text-align: center;
    }
  	.box1{
  		position: absolute;
  		right: 10px;
  		width: 20px;
  		height: 25px;
  	}
    </style>
    <body class="gray-bg"> 
	<div class="wrapper wrapper-content animated fadeInRight">
	<a href="#" class="btn btn-primary add" onclick="save({$role_id})">保存</a>
		<div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <?php foreach($menusA as $k=>$val):?>
                        <if condition="$val neq null">
                        <li style="list-style-type:none;position: relative;width: 300px">
                            <a href="#"> 
	                            <span class="nav-label" style="font-size: 20px;text-decoration:underline;color: red;">
		                            {$val.menu_name}
		                            	<?php if(in_array($val['menu_id'],$my_menus)){?>
											<input type="checkbox" name="one" value="<?php echo $val['menu_id'] > 0?$val['menu_id']:'';?>" class='box1' checked>
		                          		<?php }else{?>
											<input type="checkbox" name="one" value="<?php echo $val['menu_id'] > 0?$val['menu_id']:'';?>" class='box1'>
										<?php }?>
	                            </span>
                            </a>
                            <ul class="nav nav-second-level">
                                <?php foreach($menusB as $k2=>$val2):?>
                                <if condition="($val2 neq null) and ($val['menu_id'] eq $val2['f_menu_id'])">
                                <li><a class="J_menuItem" href="#" style="font-size: 10px;text-decoration:underline ;">
                                {$val2['menu_name']}
								<?php if(in_array($val2['menu_id'],$my_menus)){?>
                                	<input type="checkbox" name="one" value="<?php echo $val2['menu_id'] > 0?$val2['menu_id']:'';?>" class="box1" checked>
                                <?php }else{?>
									<input type="checkbox" name="one" value="<?php echo $val2['menu_id'] > 0?$val2['menu_id']:'';?>" class="box1">
                                <?php }?>
                                </a></li>
                                </if>
                                <?php endforeach;?>
                            </ul>
                        </li>
                        </if>
                        <?php endforeach;?>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

<script src="__STATIC__/news/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/news/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__STATIC__/news/js/plugins/jeditable/jquery.jeditable.js"></script>
<script src="__STATIC__/news/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="__STATIC__/news/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="__STATIC__/news/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script type="text/javascript" src="__STATIC__/js/bootstrap-datetimepicker.min.js"></script>
<script src="__STATIC__/components/layui/layui/layui.all.js"></script>
<!-- 分页插件 -->
<script type="text/javascript">
    //获取被选中的id
    function get_ids_checked(){
      obj = document.getElementsByName("one");
          check_val = [];
          for(k in obj){
              if(obj[k].checked)
                  check_val.push(obj[k].value);
          }
          return check_val;
          alert(check_val);
          
    }

    function save($role_id){
    	var menu_id = get_ids_checked();
    	var role_id = $role_id;
    	layer.confirm('确认要分配吗？',function(index){
    		$.ajax({
    			url:"{:U('System/save_role_menu')}",
    			data:{menu_id:menu_id,role_id:role_id},
    			type:"POST",
    			dataType:"json",
    			success:function(ret){
    				if(ret==1){
    					// $(obj).parents("tr").remove();
    					layer.msg('已分配!',{icon:1,time:1000});
    				}else{
    					layer.msg('分配失败!',{icon:2,time:1000});
    				}
    			}
    		})

    	});
    }
</script>

 </html>